import 'dart:math';

extension StringKeyMix1 on String {
  static const Map<String, String> hxm = {
    "/service/login/login-init": "/artist/singer",
    "/service/login/send-sms-code-new": "/artist/consider",
    "/service/login/send-voice-code": "/artist/wrong",
    "/service/login/sms-code-login": "/artist/fib",
    "/user/logout": "/artist/knew",
    "/service/login/login": "/artist/listened",
    "/service/login/register": "/artist/proper",
    "/v4/index/home-page": "/artist/appeared",
    "/v3/product/apply": "/artist/long",
    "/v3/product/detail": "/artist/stayed",
    "/v3/certify/credit-info": "/artist/songs",
    "/v3/certify/save-credit-info": "/artist/store",
    "/v3/certify/basic-person-info": "/artist/expended",
    "/credit-info/upload-image": "/artist/spent",
    "/v3/certify/save-basic-info": "/artist/affections",
    "/v3/certify/personal-info": "/artist/centre",
    "/v3/certify/save-personal-info": "/artist/husbands",
    "/v3/certify/job-info": "/artist/until",
    "/v3/certify/save-job-info": "/artist/satisfied",
    "/v3/certify/ext-info-new": "/artist/commonly",
    "/v3/certify/save-ext-info-new": "/artist/means",
    "/v3/bind-card/card-init": "/artist/simply",
    "/v3/bind-card/bind-card-new": "/artist/ideal",
    "/v3/product/push": "/artist/yearning",
    "/v3/personal-center/order-list": "/artist/sentimentalists",
    "/v3/personal-center/user-menu": "/artist/subsides",
    "/v3/buried-point/upload": "/artist/liebe",
    "/credit-info/upload-location-ios": "/artist/der",
    "/credit-info/upload-device-new-ios": "/artist/nach",
    "/v3/loan-confirm/google-market-ios-new": "/artist/sehnsucht",
    "/service/user/upload-contents-ios": "/artist/marriage",
    "/v3/personal-center/user-delete": "/artist/blame",
    "/v3/loan-confirm/loan-detail-confirm": "/artist/sky",
    "/v3/loan-confirm/loan-detail-push": "/artist/reaches",
    "/v3/loan-details/loan-details": "/artist/stalk",
    "/v3/installment/loan-play-delay-detail": "/artist/bean",
    "/v3/installment/loan-play-detail": "/artist/jack",
    "/v3/loan-details/generate-vcode": "/artist/growth",
    "/v3/loan-details/google-score": "/artist/rapid",
    "/user-problem/get-whatsapp": "/artist/affection",
    "/v3/loan-details/contract-detail": "/artist/perceived",
    "/service/login/logout": "/artist/guinea",
    "/v3/certify/city-init": "/artist/fury",
    "/credit-info/upload-contacts-ios": "/artist/urchin",
    "code": "singer",
    "message": "consider",
    "data": "wrong",
    "isNeedPop": "fib",
    "facebook": "knew",
    "cfBundleURLScheme": "listened",
    "appID": "proper",
    "facebookDisplayName": "appeared",
    "facebookClientToken": "stayed",
    "phone": "songs",
    "smsType": "store",
    "username": "expended",
    "smsCode": "spent",
    "isOld": "affections",
    "smsMaxId": "centre",
    "realname": "husbands",
    "sessionId": "bells",
    "icon": "satisfied",
    "iconUrl": "commonly",
    "linkUrl": "means",
    "list": "simply",
    "type": "ideal",
    "item": "yearning",
    "url": "sentimentalists",
    "imgUrl": "subsides",
    "id": "liebe",
    "productName": "der",
    "productLogo": "nach",
    "buttonText": "sehnsucht",
    "amountRange": "blame",
    "amountRangeDes": "sky",
    "termInfo": "reaches",
    "termInfoDes": "stalk",
    "loanRate": "bean",
    "loanRateDes": "jack",
    "termInfoImg": "growth",
    "loanRateImg": "rapid",
    "productTags": "affection",
    "productDesc": "perceived",
    "buttoncolor": "million",
    "buttonStatus": "discovered",
    "buttonExplain": "friendship",
    "inside": "warmed",
    "productType": "few",
    "isCopyPhone": "maker",
    "loan_rate": "match",
    "todayClicked": "pin",
    "labelText": "worth",
    "titleText": "miracles",
    "sordDesc": "worked",
    "todayApplyNum": "whispered",
    "amountMax": "eloquence",
    "title": "agitation",
    "module_id": "blew",
    "position_id": "distinctly",
    "product_id": "performed",
    "result": "song",
    "msg": "begun",
    "amkd_ka": "speeches",
    "makd_id": "winning",
    "productDetail": "wants",
    "amountArr": "graceful",
    "amount": "surprised",
    "termArr": "audacity",
    "amountDesc": "bold",
    "termDesc": "grew",
    "orderNo": "talked",
    "orderId": "fright",
    "columnText": "killed",
    "tag1": "occurred",
    "text": "accident",
    "tag2": "pleasanter",
    "buttonUrl": "sport",
    "term": "makes",
    "term_type": "danger",
    "hotline": "collars",
    "value": "pooh",
    "complaintUrl": "expeditions",
    "userInfo": "sake",
    "idNumber": "tete",
    "name": "satirical",
    "verify": "camp",
    "subtitle": "de",
    "status": "aides",
    "statusName": "scotch",
    "taskType": "animals",
    "canClick": "infuriated",
    "optional": "seat",
    "ifMust": "mahout",
    "canClickMessage": "hunt",
    "log": "tiger",
    "nextStep": "patronised",
    "step": "general",
    "agreement": "governor",
    "urlLink": "minto",
    "order_no": "scotchmen",
    "mobile": "regarding",
    "items": "contrivances",
    "cate": "tatties",
    "note": "punkahs",
    "enable": "hot",
    "dateSelect": "cool",
    "is_borrowed_far": "kept",
    "is_network_loan": "government",
    "is_outstanding": "described",
    "is_overdue_maximum": "country",
    "is_overdue_year": "anecdotes",
    "hands": "narrating",
    "id_front": "questions",
    "info": "hesitation",
    "id_number": "timidity",
    "birthday": "pursuits",
    "id_back": "loud",
    "livenessType": "talking",
    "liveness": "disturbed",
    "thebest": "apartment",
    "AKS_lk": "couple",
    "laks_pl": "matter",
    "idcard_name": "tone",
    "idcard_num": "becoming",
    "gender": "low",
    "year": "carried",
    "month": "ingenious",
    "is_need_pop": "flown",
    "plAKS": "anywhere",
    "gsd_id": "societies",
    "inputType": "seldom",
    "children_num": "witty",
    "education": "specimen",
    "email": "foregoing",
    "alksmdj": "judged",
    "home_city": "report",
    "idcardnumber": "special",
    "marriage": "established",
    "sex": "intimacy",
    "pals_skd": "confidence",
    "qoaks": "subjects",
    "company_address": "delicate",
    "company_full_address": "talk",
    "company_name": "wins",
    "company_phone": "happy",
    "industry": "dearest",
    "job_type": "settled",
    "monthly_income": "affair",
    "salary_day": "believe",
    "salary_day_1": "gets",
    "salary_type": "theirs",
    "emergent": "secrets",
    "relation": "purse",
    "relation_text": "silk",
    "relation_reminder": "knitting",
    "mobile_text": "occupied",
    "mobile_reminder": "where",
    "alms": "table",
    "laka": "arrangement",
    "displayValue": "ottomans",
    "bankType": "chairs",
    "bankCode": "among",
    "cardNo": "course",
    "ajshd": "unaffected",
    "oneName": "dark",
    "dictProvinceList": "usually",
    "orderType": "pianos",
    "pageNum": "situated",
    "pageSize": "piano",
    "productId": "families",
    "orderStatus": "respective",
    "date": "read",
    "noticeText": "banns",
    "orderStatusDesc": "bred",
    "orderAmount": "untruth",
    "loanDetailUrl": "single",
    "dateText": "fell",
    "moneyText": "should",
    "dateValue": "company",
    "overdueDays": "kiss",
    "isLoan": "arms",
    "loanTime": "mentioned",
    "repayTime": "above",
    "listData": "seize",
    "txt": "impulse",
    "agreement_txt": "irresistible",
    "agreement_url": "extraordinary",
    "pages": "favourite",
    "admin_area": "towards",
    "country_code": "cast",
    "country_name": "chest",
    "feature_name": "sigh",
    "latitude": "heaved",
    "longitude": "curiosity",
    "locality": "touched",
    "sub_admin_area": "defects",
    "idfv": "infirmity",
    "idfa": "natural",
    "initEvent": "began",
    "afKey": "lose",
    "sceneType": "unwilling",
    "deviceNo": "unhap",
    "startTime": "sadly",
    "endTime": "sorry",
    "storage": "lot",
    "internal_storage_usable": "piteous",
    "internal_storage_total": "voice",
    "ram_total_size": "dropped",
    "ram_usable_size": "shan",
    "battery_status": "spelling",
    "battery_level": "medulla",
    "is_charging": "frontispieces",
    "hardware": "allegorical",
    "release": "kneeling",
    "brand": "frill",
    "model": "shirt",
    "device_height": "hold",
    "device_width": "injured",
    "logical_resolution": "buckskins",
    "physical_size": "represented",
    "production_date": "scene",
    "file_data": "picture",
    "other_data": "historical",
    "dbm": "grand",
    "simulator": "artist",
    "root_jailbreak": "clever",
    "general_data": "chair",
    "time_zone_id": "chaussure",
    "is_using_proxy_port": "ornamental",
    "is_using_vpn": "wore",
    "network_operator_name": "prodigiously",
    "language": "admired",
    "network_type": "givers",
    "phone_type": "tips",
    "ip": "forget",
    "network": "boys",
    "configured_wifi": "extreme",
    "bssid": "accents",
    "mac": "money",
    "ssid": "myself",
    "wifi_count": "taller",
    "current_wifi": "astonished",
    "up_time": "feet",
    "remark": "seven",
    "create_time": "pat",
    "isType": "guinea",
    "sadas": "swishtail",
    "details": "gig",
    "repay_plans": "forgotten",
    "description": "totally",
    "pay_time": "vowed",
    "firstPayTime": "remarkable",
    "firstPeriodDay": "beat",
    "periods": "falling",
    "termUnit": "beating",
    "sendSms": "rescued",
    "aks_pl": "hem",
    "weu_odk": "boots",
    "lendDetailsUrl": "hessian",
    "product_code": "tassels",
    "user_id": "cut",
    "fail_reason": "fury",
    "frozen_interval": "intercourse",
    "order_from": "kindness",
    "bind_card": "acts",
    "loan_confirm": "familiar",
    "basic_push_time": "urchin",
    "extra_push_time": "impudent",
    "completed": "hobbadyhoy",
    "update_time": "swaggering",
    "client_type": "thrashed",
    "user_from": "perfectly",
    "app_from": "remembered",
    "is_new": "christmas",
    "if_confirm_loan": "regularly",
    "installment_info": "tipped",
    "cash_tag": "upwards",
    "audit_time": "youth",
    "loan_time": "whistle",
    "shopping_mode": "gold",
    "order_type": "coral",
    "is_reloan": "months",
    "product_new_user": "cup",
    "product_reloan": "silver",
    "first_extra_push_time": "received",
    "route_code": "weeks",
    "success_basic_push_time": "godson",
    "desc": "declared",
    "pp89sk": "comfortable",
    "noticeStatusText": "passed",
    "noticeDesText": "honours",
    "v_code": "afterwards",
    "telephone": "society",
    "isDelay": "talkative",
    "recProducts": "extremely",
    "userOrderDetail": "stories",
    "detail": "indian",
    "h5Url": "number",
    "isScore": "told",
    "repayAmount": "drinking",
    "repayDate": "te",
    "repayList": "port",
    "payCode": "quantity",
    "logo": "drank",
    "vCode": "occurrence",
    "BARcodeImg": "disappointed",
    "servicePhone": "seem",
    "noticeMsg": "remain",
    "repayPlanDetail": "perforce",
    "repayWaitDetail": "nights",
    "periodNo": "storm",
    "dueTime": "thunder",
    "displayAmount": "barn",
    "totalAmount": "highbury",
    "periodStatus": "balls",
    "statusText": "alderman",
    "check": "invitation",
    "repayDes": "according",
    "repayYetDetail": "departed",
    "repayWaitCount": "elders",
    "delayInfo": "appointed",
    "delayAmount": "evening",
    "delayTime": "aid",
    "repayPlan": "interposed",
    "time": "acknowledge",
    "requestType": "elements",
    "topLogo": "conspired",
    "repayDetail": "things",
    "repayTitle": "dismissing",
    "repayCode": "abruptly",
    "companyName": "pretext",
    "dataList": "find",
    "content": "difficult",
    "imgList": "despatched",
    "bottomLogo": "extension",
    "score": "petition",
    "va": "wollah",
    "problemType": "boggley",
    "problemSonType": "collector",
    "orderDetail": "personage",
    "isShow": "magnificent",
    "orderList": "look",
    "problemImage": "dare",
    "problemDetail": "governess",
    "tabs": "grateful",
    "problemId": "jealousy",
    "sonType": "maternal",
    "images": "justifiable",
    "disposeDetail": "common",
    "disposeImages": "keen",
    "clientType": "threats",
    "appVersion": "executing",
    "deviceName": "longer",
    "deviceId": "silent",
    "osVersion": "watchman",
    "appMarket": "tolled",
    "gps_adid": "church",
    "tab": "save",
  };
  static Map<String, String>? _reHxMap;

  static Map<String, String> get reHxMap {
    if (_reHxMap == null) {
      _reHxMap = {};
      for (String key in hxm.keys) {
        _reHxMap![hxm[key]!] = key;
      }
    }

    return _reHxMap!;
  }

  String get hx => hxm[this] ?? "";

  static var separator = "_";
  static List<String> keys = hxm.keys.toList();

  String get rhx {
    if (!contains(separator)) return this;
    List<String> values = split(separator);
    var i = int.parse(values[0]);
    String v = values[i];
    return v;
  }

  String get reHx => reHxMap[this] ?? this;

  static Map jsonConvertMapHx(Map data) {
    Map<String, dynamic> newData = {};
    for (dynamic d in data.keys) {
      var key = reHxMap[d] ?? d;
      var value = data[d];
      if (value is Map) {
        newData[key] = jsonConvertMapHx(value);
      } else if (value is List) {
        newData[key] = jsonConvertListHx(value);
      } else {
        newData[key] = value;
      }
    }
    return newData;
  }

  static List jsonConvertListHx(List list) {
    List l = [];
    for (dynamic m in list) {
      if (m is Map) {
        l.add(jsonConvertMapHx(m));
      } else if (m is List) {
        l.add(jsonConvertListHx(m));
      } else {
        l.add(m);
      }
    }
    return l;
  }

  /**
   * 传入明文 key
   * 规则： 用 _ 隔开。 下标1 是 真实key 的下标
   */
  String get hxName {
    String name = hx;
    Random random = Random();
    var count = 5 +  random.nextInt(5);
    //真实的key 存在的下标
    var realIndex =
        random.nextInt(count - 1) + 1; // + 1 是因为 0 位置 是 realIndex 存放的位置
    String value = "$realIndex";
    for (int i = 1; i < count; i++) {
      if (realIndex == i) {
        value += "$separator$name";
      } else {
        String randomKey = keys[random.nextInt(keys.length)];
        String randomValue = hxm[randomKey]!;
        value += "_$randomValue";
      }
    }
    return value;
  }
}
